<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('信件录入-编辑页面')"/>
    <link rel="stylesheet" type="text/css" th:href="@{/ajax/libs/qxEasyUI/themes/default/easyui.css}">
</head>
<body style="background-color: #F4F6FA;">
<div class="main-content" style="margin: 0;padding: 0;">
    <form id="telInputForm" class="form-horizontal" style="background-color: #F4F6FA" th:object="${mmailGetDeal}">
        <input type="hidden" name="pkId" th:field="*{pkId}"/>
        <input type="hidden" name="stateFlag" th:field="*{stateFlag}"/>
        <input type="hidden" name="wsCode" th:field="*{wsCode}"/>
        <input id="flagInt" name="flagInt" type="hidden" th:field="*{flagInt}"/>
        <input id="flagString" name="flagString" type="hidden" th:field="*{flagString}"/>
        <input id="spareInt" name="spareInt" type="hidden" th:field="*{spareInt}"/>
        <div class="col-sm-12 grid-container" style="display: flex">
            <!--     左       -->
            <div class="col-sm-8 entering-page">
                <!--   来电基本信息     -->
                <div class="col-sm-12 tltieBoder">
                    <div class="blueBorder"></div>
                    <h4 style="margin:0 0 0 10px">来信人信息</h4>
                </div>
                <div class="col-sm-6">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-4 control-label is-required entering-pd">来信人</label>
                            <div class="col-sm-8">
                                <input name="fromName" placeholder="请输入"
                                       class="form-control phoneName" type="text" th:field="*{fromName}"
                                       maxlength="5" required="">
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-4 control-label entering-pd">联系电话</label>
                            <div class="col-sm-8">
                                <input name="fromTel" placeholder="请输入"
                                       class="form-control relationPhone"
                                       type="text" th:field="*{fromTel}"
                                       >
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-4 control-label is-required entering-pd">来信类别</label>
                            <div class="col-sm-8">
                                <select name="dfmClaNo" id="dfmClaNo" required
                                        th:with="telTypes=${@commonServiceImpl.findTelType()}"
                                        onchange="dropChgSendTextOnly(this,'dfmClaName');"
                                        class="form-control formSelect">
                                    <option value="">--请选择--</option>
                                    <th:block th:each="item : ${telTypes}">
                                        <option th:text="${item['CSText']}" th:value="${item['CSValue']}"
                                                th:selected="${item['CSValue']} == *{dfmClaNo}"></option>
                                    </th:block>
                                </select>
                                <input type="hidden" name="dfmClaName" id="dfmClaName" th:field="*{dfmClaName}"/>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-xs-4 control-label entering-pd">建议公开</label>
                            <div class="col-xs-8" style="white-space:nowrap;">
                                <label class="check-box">
                                    <input name="openX" value="1" type="radio">是
                                </label>
                                <label class="check-box">
                                    <input name="openX" value="0" type="radio" checked>否（效能办）
                                </label>
                            </div>
                        </div>
                    </div>

                </div>
                <!--关键词等-->
                <div class="col-sm-6">

                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-xs-4 control-label entering-pd">地址</label>
                            <div class="col-xs-8">
                                <select name="fmAreaNo" id="fmAreaNo" required
                                        th:with="area=${@commonServiceImpl.findArea()}"
                                        onchange="dropChgSendTextOnly(this,'fmAreaName');"
                                        class="form-control" >
                                    <option value="">--请选择--</option>
                                    <th:block th:each="item : ${area}">
                                        <option th:text="${item['CSText']}" th:value="${item['CSValue']}" th:selected="${item['CSValue'] == user.areaNo}"></option>
                                    </th:block>
                                </select>
                                <input type="hidden" name="fmAreaName" id="fmAreaName" th:value="*{fmAreaName}"/>
                                <input name="fmAddress" placeholder="请输入"
                                       class="form-control scene theAddress" type="text" th:field="*{fmAddress}"
                                       maxlength="60">
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-xs-4 control-label entering-pd">性别</label>
                            <div class="col-xs-8">
                                <label class="check-box">
                                    <input name="fromSex" value="1" th:checked="*{fromSex == '1'}" type="radio">男
                                </label>
                                <label class="check-box">
                                    <input name="fromSex" value="0" th:checked="*{fromSex == '0'}" type="radio" checked>女
                                </label>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-xs-4 control-label entering-pd">电子邮箱</label>
                            <div class="col-xs-8">
                                <input name="fmEmail" placeholder="请输入"
                                       class="form-control relationPhone" th:field="*{fmEmail}"
                                       type="text">
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-xs-4 control-label entering-pd is-required">内容类别</label>
                            <div class="col-xs-8">
                                <input id="qxCT" th:value="*{dCntAName}"
                                       style="width:187px;height:31px;border-radius: 5px;">
                                <input id="txtDcntAcode" name="dCntACode" type="hidden" th:field="*{dCntACode}"/>
                                <input id="txtDCntAName" name="dCntAName" type="hidden" th:field="*{dCntAName}"/>
                            </div>
                        </div>
                    </div>


                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-xs-4 control-label entering-pd">同意公开</label>
                            <div class="col-xs-8" style="white-space:nowrap;">
                                <label class="check-box">
                                    <input name="openFrom" value="1" th:checked="*{openFrom == 1}" type="radio">是
                                </label>
                                <label class="check-box">
                                    <input name="openFrom" value="0" th:checked="*{openFrom == 0}" type="radio" checked>否（来信人同意否）
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12" th:if="*{yspare != null}">
                    <div class="form-group">
                        <label class="col-xs-2 control-label entering-pd">附件</label>
                        <div class="col-xs-10">
                            <div class="col-sm-12 select-table table-striped">
                                <table id="imgContainer" class="table">
                                    <thead>
                                    <tr class="title">
                                        <th style="text-align: center">文件</th>
                                        <th style="text-align: center">操作</th>
                                    </tr>
                                    <tr th:each="name:${names}">
                                        <td style="text-align: center">[[${name}]]</td>
                                        <td style="text-align: center"><a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="chkFile(this)"><i class="fa"></i>查看</a></td>
                                    </tr>
                                    </thead>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!--右-->
            <div class="col-sm-6 entering-page">
                <div class="col-sm-12">
                    <!--   工单基本信息     -->
                    <div class="col-sm-12 tltieBoder">
                        <div class="blueBorder"></div>
                        <h4 style="margin:0 0 0 10px">来信内容详情</h4>
                    </div>
                    <!--工单主题,工单编号,工单性质...-->
                    <div class="col-sm-12 entering-mt">
                        <div class="form-group">
                            <label class="col-sm-2 control-label is-required entering-pd">主题</label>
                            <div class="col-sm-10">
                                <input name="fromTopic" placeholder="请输入"
                                       class="form-control" type="text"
                                       maxlength="100" th:field="*{fromTopic}"
                                       required>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label entering-pd is-required">信件来源</label>
                            <div class="col-sm-10">
                                <select id="ddlFrom" name="fmSpare" class="form-control formSelect" onchange="dropChgSendTextOnly(this,'spareString');">
                                    <option value="51610" th:selected="'51610' == *{fmSpare}">问政四川</option>
                                    <option value="51620" th:selected="'51620' == *{fmSpare}">麻辣社区</option>
                                    <option value="51630" th:selected="'51630' == *{fmSpare}">人民网</option>
                                    <option value="51640" th:selected="'51640' == *{fmSpare}">人大件</option>
                                    <option value="51650" th:selected="'51650' == *{fmSpare}">政协件</option>
                                    <option value="51600" th:selected="'51600' == *{fmSpare}">其他</option>
                                </select>
                                <input id="spareString" name="spareString" type="hidden" th:field="*{spareString}"/>
                            </div>
                        </div>
                    </div>
                    <!--是否自动延期-->
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label entering-pd">自动延期</label>
                            <div class="col-sm-8">
                                <label class="check-box">
                                    <input name="isAutoExtend" value="1" th:checked="*{isAutoExtend == 1}" type="radio">是
                                </label>
                                <label class="check-box">
                                    <input name="isAutoExtend" value="0" type="radio" th:checked="*{isAutoExtend == 0 || isAutoExtend == null}" checked>否
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label entering-pd">重复来信</label>
                            <div class="col-sm-8">
                                <label class="check-box">
                                    <input name="repeatFlag" value="1" th:checked="*{repeatFlag == 1}" type="radio">是
                                </label>
                                <label class="check-box">
                                    <input name="repeatFlag" value="0" th:checked="*{repeatFlag == 0}" type="radio" checked>否
                                </label>
                            </div>
                        </div>
                    </div>
                    <!--来信类容-->
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-xs-2 control-label entering-pd is-required">来信内容</label>
                            <div class="col-xs-10">
                            <textarea name="fmContent" id="fmContent"  maxlength="4000"
                                      class="form-control phoneRemark" th:field="*{fmContent}"
                                      style="height: 160px" required></textarea>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <div class="col-sm-12 mb30">
            <!-- 按钮-->
            <div class="col-sm-12"
                 style="margin-bottom: 10px;display: flex;justify-content: center;flex-direction: row;">
                <button type="button" class="btn btn-sm btn-success" onclick="editMail()">保存
                </button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <button type="button" class="btn btn-sm btn-warning" onclick="gclose()">关闭
                </button>&nbsp;
            </div>
        </div>
    </form>
</div>

<th:block th:include="include :: footer"/>
<script th:src="@{/ajax/libs/qxEasyUI/jquery.easyui.min.js}"></script>
<script>
    var prefix = ctx + "system/wsMail";
    var areaSelect = document.getElementById('fmAreaNo');
    var selectText = areaSelect.options[areaSelect.selectedIndex].text;
    if(selectText) {
        document.getElementById('fmAreaName').value = selectText;
    }

    $('#qxCT').combotree({
        url: '/system/common/findContentCate',
        required: false,
        onSelect: function (record) {
            $("#txtDcntAcode").val(record.id);
            $("#txtDCntAName").val(record.text);
            $('.combo-text').removeClass('error');
        }
    });

    function editMail(){
        var flag = $.validate.form();
        if($("#txtDcntAcode").val() == '') {
            $('.combo-text').addClass('error');
            flag = false;
        }
        else {
            $('.combo-text').removeClass('error');
        }
        if(flag){
            var data = $('#telInputForm').serializeArray();
            var url = prefix + '/edit';
            $.operate.saveTab(url,data);
        }
    }

    //    关闭
    function gclose() {
        $.modal.closeTab();
    }


    function OftenMailWordsChg(e,acpId) {
        temp = $(e.options[e.selectedIndex]).attr('data');
        document.getElementById(acpId).value = temp;
    }

    function chkFile(obj){
        var fileName = $(obj).parents('tr').find('td:first-child').text();
        var wsCode = $('#wsCode').val();
        var url = prefix+"/chkFile?wsCode="+wsCode+"&fileName="+fileName;
        if (fileName.endsWith(".doc")
            || fileName.endsWith(".xls")
            || fileName.endsWith(".ppt")
            || fileName.endsWith(".pdf")
        )
        {
            var eleForm = $("<form method='get'>" +
                "<input name='wsCode' type='hidden' value='"+wsCode+"'>" +
                "<input name='fileName' type='hidden' value='"+fileName+"'></form>");
            eleForm.attr("action",url);
            $(document.body).append(eleForm);
            //提交表单，实现下载
            eleForm.submit();
        }else{
            window.open(url,"附件",'left=100,top=20,height=700,width=720,toolbar=yes,menubar=yes,scrollbars=auto');
        }
    }
</script>
</body>
</html>